# Copyright (c) 2019 Presto Labs Pte. Ltd.
# Author: donggu

import json

from experimental.prophet.graph import graph


def legacy_sampler(proto_feed, feature_list, sampler_type, config=None):
  if config is None:
    config = {}

  attrs = {
      'sampler_type': sampler_type,
      'config': json.dumps(config),
  }

  with graph.control_if(None):
    node = graph.create_node('fastfeed.LegacySampler', [proto_feed, *feature_list],
                             attrs=attrs).outputs
    return node
